Merged
Conversation
fme/downscaling/data/static.py — major refactor: - StaticInput: removed coords field; now just holds data; subset() takes slices (not intervals) - Added _load_coords_from_ds(), load_fine_coords_from_path() for loading coords from files - Added _has_legacy_coords_in_state(), _has_coords_in_state(), _sync_state_coordinates() for backwards-compat state migration - StaticInputs: added coords: LatLonCoordinates as first-class field; removed per-field coord validation; subset() now returns updated coords; to_device() moves coords too; get_state() includes top-level "coords"; from_state() raises if coords absent; added from_state_backwards_compatible() - _get_normalized_static_input(): returns (StaticInput, LatLonCoordinates) tuple - load_static_inputs(): no longer accepts None; validates coord consistency across fields fme/downscaling/data/test_static.py — full replacement with new test suite covering all new APIs fme/downscaling/data/__init__.py — added load_fine_coords_from_path export fme/downscaling/test_models.py — updated make_static_inputs() to new StaticInputs interface fme/downscaling/inference/test_inference.py — updated get_static_inputs() helper fme/downscaling/train.py — guarded load_static_inputs call against None config# Please enter the commit message for your changes. Lines starting
ff04394 to
665dfb9
Compare
frodre
commented
Mar 23, 2026
| ) | ||
|
|
||
| @classmethod | ||
| def from_state_backwards_compatible( |
Collaborator
Author
There was a problem hiding this comment.
This method gets used in #999, but there will be a CheckpointModelConfig gate on calling this without coords available in the state or the configuration.
AnnaKwa
approved these changes
Mar 23, 2026
Contributor
AnnaKwa
left a comment
There was a problem hiding this comment.
Mostly LGTM, one request that doesn't need to be reviewed.
fme/downscaling/data/static.py
Outdated
| "coords": self.coords.get_state(), | ||
| } | ||
|
|
||
| def load_fine_coords_from_path(path: str) -> LatLonCoordinates: |
Contributor
There was a problem hiding this comment.
It looks like this code is duplicated in _get_normalized_static_input. Can this helper and its tests be removed? I think _load_coords_from_ds is simple enough that it doesn't need multiple tests.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
PR 2/3 for #971 split
Changes:
Move lat/lon coordinates from individual
StaticInputfields to the parentStaticInputscontainerStaticInput.subsetnow takesslicearguments directly instead ofClosedIntervalsExtract
_load_coords_from_dswith flexible coordinate name matching (lat/latitude/grid_yt, etc.)Add
StaticInputs.from_state_backwards_compatibleto handle legacy checkpoints (coords per-field) and config-based loading (no coords in checkpoint)load_static_inputsnow requires at least one field and validates coordinate consistency across fieldsTests added